﻿@*@using UCosmic.Www.Mvc.Areas.InstitutionalAgreements.Models.ManagementForms
@model IEnumerable<InstitutionalAgreementMappedSearchResult>
@{
    ViewBag.Title = "BrowseByMap";
}
<h2>
    Browse Institutional Agreements</h2>
@section Scripts {

    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.6&sensor=false"></script>

}
<div id="map_canvas" style="width: 875px; height: 600px">
</div>

<script type="text/javascript">
    //display the map
    var stockholm = new google.maps.LatLng(0,0);
    var myOptions = {
        zoom: 2,
        center: stockholm,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }; 
    
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
    @foreach (var item in Model)
    {
    <text>  
          var latLng = new google.maps.LatLng('@(item.Latitude)', '@(item.Longitude)');
          var title = '@(item.Title)';  
         
          var contentString = '<a href="@Url.Action(MVC.InstitutionalAgreements.ManagementForms.Edit(item.EntityId, Request.RawUrl))">' + title + '</a>' ;
          var marker = new google.maps.Marker({
             position: latLng,
             map: map
          });

          bindInfoW(marker, contentString, infoWindow);

          var infoWindow = new google.maps.InfoWindow();
          
          function bindInfoW(marker, contentString, infowindow)
            {
             google.maps.event.addListener(marker, 'click', function () {
                infoWindow.setContent(contentString);
                infoWindow.open(map, marker);
                });
            }
   
    </text>
    }
</script>

*@